<?php


namespace app\admin\controller;


//use app\admin\service\GenerateToken;
//php7 新语法 use 多引入！
use app\common\model\System;
use app\lib\exception\admin\{
    OrderException
};
use think\facade\Request;
use app\admin\model\Admin;

class Login
{
    /**
     * 用户登录
     * @param Request $request
     * @return \think\response\Json
     * @throws OrderException
     * @throws \app\lib\exception\admin\ErrorsException
     * @throws \app\lib\exception\admin\SQLException
     */
    public function Login(Request $request){
        //查找所有系统设置表数据
        //$system = System::getListField()->toArray();

        //获取登录信息
        $username = $request::post('username');
        $password = $request::post('password');
        $getJwtToken = Admin::AdminUser($username,$password);
        $res = [
                'code' => 20000,
                'token' =>$getJwtToken,
            ];
        if(!$res){
            throw new OrderException();
        }
        return json($res);
    }
}